<template>
  <div class="like-wrap">
    <!-- <van-list
      :finished="finished"
      loading-text="يۈكسىلىۋاتىدۇ"
      error-text="مەغلۇپ بولدى"
      :offset="50"
      v-model="loading"
      @load="onLoad"
      :error.sync="error"
    >
      <div class="list">
        <VideoCover :show="true" v-for=" (item,index) in list" :key="index" :info="item"></VideoCover>
      </div>
    </van-list>-->
    <waterfall :col="3" :data="list">
      <template>
        <VideoCover v-for="(item, index) in list" :key="index" :info="item" />
      </template>
    </waterfall>
    <div class="empty" v-if="emptyList"></div>
  </div>
</template>
<script>
import VideoCover from "@/components/VideoCover.vue";
import { shareFrend, shareMoments, getQueryVariable } from "@/utils";
export default {
  components: {
    VideoCover
  },
  data() {
    return {
      list: [],
      emptyList: false,
      pageSize: 18,
      pageNum: 0,
      finished: false,
      loading: false,
      error: false
    };
  },
  mounted() {
    shareMoments(this);
    shareFrend(this);
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      this.pageNum++;
      this.$http
        .get("/getCollectVideo", {
          params: {
            pageSize: this.pageSize,
            pageNum: this.pageNum
          }
        })
        .then(res => {
          if (res.length < this.pageSize) {
            this.finished = true;
          }
          this.list = this.list.concat(res);
          if(!this.list.length){
            this.emptyList = true
          }
          this.loading = false;
        })
        .catch(err => {
          this.loading = false;
          this.error = true;
          this.$toast(err);
        });
    }
  }
};
</script>
<style lang="scss" scoped>
.like-wrap {
  min-height: 100vh;
  background-color: #ffffff;
  padding: 0 1vw;
  /* .list {
    display: flex;
    justify-content: space-between;
    padding: 0 1%;
    flex-wrap: wrap;
    &::after {
      content: "";
      width: 32%;
      display: block;
      height: 0;
    }
  } */
}
.empty {
        min-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 35px;
    }
</style>